//
//  HLIMKitSessionMsgDataSource.h
//  YueYue
//
//  Created by hulu001 on 2024/1/11.
//

#import <Foundation/Foundation.h>
#import "HLIMKitSessionDataProvider.h"
#import "HLIMSessionConfig.h"
#import "HLIMKitMessageModel.h"

NS_ASSUME_NONNULL_BEGIN

@interface HLIMKitSessionMsgDataSource : NSObject


- (instancetype)initWithSession:(NIMSession *)session sessionConfig:(id<HLIMSessionConfig>)sessionConfig;

@property (nonatomic, strong) NSMutableArray    *items;

- (NSInteger)indexAtModelArray:(HLIMKitMessageModel *)model;

//数据对外接口
- (void)loadHistoryMessagesWithComplete:(void(^)(NSInteger index , NSArray *messages ,NSError *error))handler;
- (void)loadNewMessagesWithComplete:(void(^)(NSInteger index , NSArray *messages ,NSError *error))handler;

//添加消息，会根据时间戳插入到相应位置
- (NSArray<NSNumber *> *)insertMessageModels:(NSArray*)models;

//添加消息，直接插入消息列表末尾
- (NSArray<NSNumber *> *)appendMessageModels:(NSArray *)models;

//删除消息
- (NSArray<NSNumber *> *)deleteMessageModel:(HLIMKitMessageModel*)model;

//根据范围批量删除消息
- (NSArray<NSNumber *> *)deleteModels:(NSRange)range;

//复位消息
- (void)resetMessages:(void(^)(NSError *error)) handler;

//清理缓存数据
- (void)cleanCache;

@end

NS_ASSUME_NONNULL_END
